#include <string.h>
class State {
public:
  boolean SelectButton;
  boolean StartButton;

  byte LeftStickX;     // left Joystick X axis 0 - 255, 128 is mid
  byte LeftStickY;     // left Joystick Y axis 0 - 255, 128 is mid
  byte RightStickX;    // right Joystick X axis 0 - 255, 128 is mid
  byte RightStickY;    // right Joystick Y axis 0 - 255, 128 is mid

  byte PressureUp;     // digital Pad Up button Pressure 0 - 255
  byte PressureRight;  // digital Pad Right button Pressure 0 - 255
  byte PressureDown;   // digital Pad Down button Pressure 0 - 255
  byte PressureLeft;   // digital Pad Left button Pressure 0 - 255

  byte PressureL2;     // digital Pad L2 button Pressure 0 - 255
  byte PressureR2;     // digital Pad R2 button Pressure 0 - 255
  byte PressureL1;     // digital Pad L1 button Pressure 0 - 255
  byte PressureR1;     // digital Pad R1 button Pressure 0 - 255

  byte PressureTriangle;   // digital Pad Triangle button Pressure 0 - 255
  byte PressureCircle;     // digital Pad Circle button Pressure 0 - 255
  byte PressureCross;      // digital Pad Cross button Pressure 0 - 255
  byte PressureSquare;     // digital Pad Square button Pressure 0 - 255

  void print();
  void printDebug();
  void printDiff(const State &o);
  boolean operator==(const State &o);
  boolean operator!=(const State &o);
  State();
};

State::State(){
  memset(this, 0, sizeof(State));
}
boolean State::operator==(const State &o){
  return memcmp(this, &o, sizeof(State))==0?true:false;  
}

boolean State::operator!=(const State &o){
  return !operator==(o);
}

void State::printDiff(const State &o){
  if (LeftStickX != o.LeftStickX){
    Serial.print("LeftStickX ");
    Serial.println(LeftStickX , DEC);
  }

  if (LeftStickY != o.LeftStickY){
    Serial.print("LeftStickY ");
    Serial.println(LeftStickY , DEC);
  }

  if (RightStickX != o.RightStickX){
    Serial.print("RightStickX ");
    Serial.println(RightStickX, DEC);
  }

  if (RightStickY != o.RightStickY){
    Serial.print("RightStickY ");
    Serial.println(RightStickY, DEC);
  }

  if(PressureUp != o.PressureUp){
    Serial.print("UP ");
    Serial.println(PressureUp   , DEC);
  }
  if(PressureRight != o.PressureRight){
    Serial.print("RIGHT ");
    Serial.println(PressureRight, DEC);
  }
  if(PressureDown != o.PressureDown){
    Serial.print("DOWN ");
    Serial.println(PressureDown , DEC);
  }
  if(PressureLeft != o.PressureLeft){
    Serial.print("LEFT ");
    Serial.println(PressureLeft , DEC);
  }
  if(PressureL1 != o.PressureL1){
    Serial.print("L1 ");
    Serial.println(PressureL1, DEC);
  }
  if(PressureR1 != o.PressureR1){
    Serial.print("R1 ");
    Serial.println(PressureR1, DEC);
  }
  if(PressureL2 != o.PressureL2){
    Serial.print("L2 ");
    Serial.println(PressureL2, DEC);
  }
  if(PressureR2 != o.PressureR2){
    Serial.print("R2 ");
    Serial.println(PressureR2, DEC);
  }
  if(PressureTriangle != o.PressureTriangle){
    Serial.print("Triangle ");
    Serial.println(PressureTriangle, DEC);
  }
  if(PressureCircle != o.PressureCircle){
    Serial.print("Circle ");
    Serial.println(PressureCircle  , DEC);
  }
  if(PressureCross != o.PressureCross){
    Serial.print("Cross ");
    Serial.println(PressureCross   , DEC);
  }
  if(PressureSquare != o.PressureSquare){
    Serial.print("Square ");
    Serial.println(PressureSquare  , DEC);
  }
}

void State::printDebug(){
  Serial.print("LeftStickX ");
  Serial.println(LeftStickX , DEC);
  Serial.print("LeftStickY ");
  Serial.println(LeftStickY , DEC);
  Serial.print("RightStickX ");
  Serial.println(RightStickX, DEC);
  Serial.print("RightStickY ");
  Serial.println(RightStickY, DEC);

  Serial.print("UP ");
  Serial.println(PressureUp   , DEC);
  Serial.print("RIGHT ");
  Serial.println(PressureRight, DEC);
  Serial.print("DOWN ");
  Serial.println(PressureDown , DEC);
  Serial.print("LEFT ");
  Serial.println(PressureLeft , DEC);

  Serial.print("L1 ");
  Serial.println(PressureL1, DEC);
  Serial.print("R1 ");
  Serial.println(PressureR1, DEC);
  Serial.print("L2 ");
  Serial.println(PressureL2, DEC);
  Serial.print("R2 ");
  Serial.println(PressureR2, DEC);

  Serial.print("Triangle ");
  Serial.println(PressureTriangle, DEC);
  Serial.print("Circle ");
  Serial.println(PressureCircle  , DEC);
  Serial.print("Cross ");
  Serial.println(PressureCross   , DEC);
  Serial.print("Square ");
  Serial.println(PressureSquare  , DEC);
}

void State::print(){
  Serial.print(LeftStickX , DEC);
  Serial.print(LeftStickY , DEC);
  Serial.print(RightStickX, DEC);
  Serial.print(RightStickY, DEC);

  Serial.print(PressureUp   , DEC);
  Serial.print(PressureRight, DEC);
  Serial.print(PressureDown , DEC);
  Serial.print(PressureLeft , DEC);

  Serial.print(PressureL1, DEC);
  Serial.print(PressureR1, DEC);
  Serial.print(PressureL2, DEC);
  Serial.print(PressureR2, DEC);

  Serial.print(PressureTriangle, DEC);
  Serial.print(PressureCircle  , DEC);
  Serial.print(PressureCross   , DEC);
  Serial.print(PressureSquare  , DEC);
}



